The present invention relates to an apparatus and method for encoding images and a medium in which an image encoding program has been recorded, and more particularly, is applicable to the case of transmitting images upon compression coded to an image decoding apparatus.
In the communication system for transmitting the image data coded and compressed at an image encoding apparatus and for expanding and decoding the transmitted image data at an image decoding apparatus, and in the compressed image recording and reproducing apparatus for recording an image data compressed and for outputting the compressed image data after expanding at the time of reproduction, the bidirectionally predictive coding system adopted by the MPEG (Moving Picture Experts Group) standard has been used as the method to compress the image data for example. In this bidirectionally predictive coding system, the efficiency of coding has been improved by using bidirectional prediction. In the bidirectionally predictive coding system, three types of coding, intra frame coding, interframe directionally predictive coding and bidirectionally predictive coding, are conducted and images according to each coding type are called as I picture (intra-coded picture), P picture (predictive coded picture) and B picture (bidirectionally predictive coded picture) respectively.
However, in the image encoding apparatus for compressing and coding the image data in utilizing the bidirectionally predictive coding system adopted by the MPEG standard, a buffer for verifying the decoding that the input buffer of image decoding apparatus is considered at the side of image encoding apparatus virtually, that is VBV (Video Buffering Verifier) buffer, is assumed in order to prove that the capacity of an input buffer possessed by the image decoding apparatus for expanding the compressed and coded image data would not be destroyed, and the volume of data to be generated in the image encoding apparatus is controlled not to overflow or underflow the permissible limits of the data occupancy rate of the VBV buffer (refer to xe2x80x9cMultimedia, by Television Academic Association MPEGxe2x80x9d, p.115, published by Ohm-sha).
More specifically, in the case where the coded data is transmitted at the fixed bit rate from the image encoding apparatus, as shown in FIG. 1, the image data is generated from the VBV buffer in a state where the data occupancy rate of the VBV buffer would not underflow or overflow when the bit stream of the image data is inputted in the VBV buffer at the specified bit rate.
In the image decoding apparatus, the bit stream transmitted from the image encoding apparatus is decoded for each image data of one frame as an unit via the VBV buffer. Thereby, even if the bit rate of the coded data transmitted from the image data encoding apparatus is constant, a picture each having a different data size can be decoded surely. For example, the frame coded using the intra frame image data (that is, intra-coded I picture) has larger volume of codes per frame as compared with the frame coded using motion compensation from temporally preceding and succeeding frames. However, each picture can be surely decoded if the decoding is performed without the VBV buffer underflow or overflow.
In FIG. 1, the slope of each line segment x shows the fixed bit rate of data stream to be transmitted and each position x1 of each line segment x shows the data occupancy rate in the VBV buffer. Also, the line segment y shows a state in which one frame of data is read out from the VBV buffer as I picture, B picture, and P picture so that the data occupancy rate of VBV buffer is rapidly reduced.
However, as shown in FIG. 2, when the picture having data exceeding the amount of predetermined data occupancy rate appears from the VBV buffer, underflow occurs in the VBV buffer. This means that the image can not be decoded because of shortage of the data to decode the picture (the part under xe2x80x9c0xe2x80x9d in the figure) when more volumes of codes than the target code generation volume are generated due to complexity of image or vigorous movement although the target code generation volume is set according to the rate control.
The function of this VBV buffer is described in Annex C of the ISO (International Organization for Standardization)/IEC (International Electrotechnical Commission) 13818-2 (Video part of MPEG2). However, as to the function of the image decoding apparatus when underflow and over flow occur in the VBV buffer, it has not been described.
As a method for preventing the occurrence of underflow in the VBV buffer, a method to prevent the occurrence of underflow in the VBV buffer by setting the fixed threshold value to the VBV buffer and by skipping (stopping the encoding processing for the image) pictures when the data occupancy rate in the VBV buffer is under the threshold value, is proposed.
However, this method raises the possibility of conducting the skip processing on any image coding type of pictures. In this case, since the volume of codes to be generated (i.e., data rate) of I picture, which includes the most important image data in a picture quality in case of decoding, is larger than P picture and B picture, it is considered that I picture would be skipped more than P picture and B picture. Accordingly, in the case where I picture is skipped, it exerts an effect upon the quality of image of P picture and B picture which are predictive images of I picture and there was the possibility of degrading the overall picture quality.
The present invention has been done considering the above point and is proposing an image encoding apparatus and an image encoding method capable of preventing underflow in the buffer for verifying decoding without degrading the picture quality.
To solve the above point, in this invention, the coding control means calculates the code generation volume of image coded. In accordance with the calculated result, the coding control means controls the coding means so that the coding processing for the first, second, or third image which is currently coded is stopped, in the case where the data occupancy rate of the image coded in the buffer of the image decoding apparatus is smaller than the first, second or the third threshold value corresponding to the first, second, or the third image currently coded from among the first, second and/or the third threshold values set corresponding to the first image to be intra-coded, the second image to be directionally predictive coded and the third image to be bidirectionally predictive coded.
Also, in the case where the coding process to the first image, the second image or the third image being coded is stopped, the buffer size for the following image is secured in the buffer of the image decoding apparatus.
Moreover, by setting the first, second and/or third threshold values according to the importance of image coding types in case of decoding the image, the buffer size of image with higher importance is be secured preferentially in the buffer of the image decoding apparatus.
In this way, the image encoding apparatus and the image encoding method which can prevent the occurrence of underflow in the buffer of image decoding apparatus can be realized without degrading the picture quality.
Further, coding means compresses and codes an input image data per picture by coding method corresponding to image coding types, and occupancy rate calculating means calculates data occupancy rate of the virtual buffer corresponding to the input buffer in the image decoding apparatus. Coding difficulty calculating means calculates the degree of coding difficulty showing the degree of coding difficulty of the picture succeeding the picture coded, and picture skip controlling means codes a picture to be coded next as the picture being formed by skip macro blocks in the case that the data occupancy rate to be calculated by the occupancy rate calculating means is lower than the specified data occupancy rate judging threshold value and the degree of coding difficulty to be calculated by the coding difficulty calculating means agrees with the specified standard, when coding of one picture is finished.
In this way, this invention can obtain the effect of avoiding the underflow of the virtual buffer corresponding to the input buffer in the image decoding apparatus by controlling the influence on the picture quality as small as possible.